home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows Expert
/
Windows Expert.iso
/
windownt
/
logoff.zip
/
LOGOFF.C
next >
Wrap
C/C++ Source or Header
|
1993-06-29
|
1KB
|
59 lines
//
// Logoff
// ======
//
// Programm Logoff.exe
//
//
#include <windows.h>
#include <stdio.h>
void main(argc,argv)
int argc;
char *argv[];
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
CHAR buffer[80];
/* Get the Process Token */
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
printf ( buffer, "OpenProcessToken Error #%d", GetLastError ());
}
/* Get the LUID for shutdown privilege */
LookupPrivilegeValue(NULL, TEXT("SeShutdownPrivilege"),
&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; /* one privilege to set */
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
/* Get shutdown privilege for this process. */
if (!AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0)) {
printf ( buffer, "AdjustTokenPrivileges Error #%d", GetLastError ());
}
if (argc<2){
ExitWindowsEx(EWX_LOGOFF,0);
exit(1);}
if ((argv[1][0]== 102) || (argv[1][0]== 70)){
ExitWindowsEx(EWX_FORCE,0);
exit(1);}
printf("Logoff - Utility V. 1.01 \n");
printf("Logoff - normal Logoff \n");
printf("Logoff f - FORCED Logoff \n");
printf("This utility may be freely distributed as long as it remains unchanged.\n");
printf("Please forward suggestions to Martin Sieber (100142,2756)\n");;
printf("Dedicated to the Windows NT community\n");
}